Page({
  data: {
    daysOfMonth: [],
    currentDay: ''
  },

  onLoad: function () {
    this.generateDaysOfMonth();
  },

  generateDaysOfMonth: function () {
    const date = new Date();
    const year = date.getFullYear();
    const month = date.getMonth() + 1;

    const firstDay = new Date(year, month - 1, 1);
    const startDayOfWeek = firstDay.getDay();

    const daysInMonth = new Date(year, month, 0).getDate();

    const days = [];
    let day = 1;
    for (let i = 0; i < 42; i++) {
      if (i >= startDayOfWeek && day <= daysInMonth) {
        days.push({ day });
        day++;
      } else {
        days.push({ day: '' });
      }
    }

    this.setData({ daysOfMonth: days });
  },

  signIn: function () {
    const date = new Date();
    const day = date.getDate();

    this.setData({ currentDay: day });
  }
})